home *** CD-ROM | disk | FTP | other *** search
- #define PRECOGNITION_UTILS_BODY
-
- #include "precognition_utils.h"
- #include "minmax.h"
- #include <proto/exec.h>
- #include <proto/intuition.h>
- #include <proto/graphics.h>
- #include "amigamem.h"
- #include <string.h>
-
- TextAttr pcg_Topaz80 =
- { "topaz.font", TOPAZ_EIGHTY, FS_NORMAL, FPF_ROMFONT };
-
-
-
-
-
- #define RES_MASK (HIRES+LACE)
- #define LO_RES 0
- #define LO_RES_INTERLACE LACE
- #define HI_RES HIRES
- #define HIRES_INTERLACE HIRES+LACE
-
- tPoint pcg_AspectRatio( USHORT ViewModes )
- {
- tPoint ratio;
- USHORT ScreenRes;
-
- ScreenRes = (ViewModes & (RES_MASK)); /* Ignore other bits. */
- switch (ScreenRes)
- {
- case LO_RES:
- case HIRES_INTERLACE:
- ratio.x = 1;
- ratio.y = 1;
- break;
-
- case LO_RES_INTERLACE:
- ratio.x = 1;
- ratio.y = 2;
- break;
-
- case HIRES:
- ratio.x = 2;
- ratio.y = 1;
- break;
- }
- return ratio;
- }
-
-
-
- void ChainGadgets( Gadget *start_of_chain, Gadget *gadget )
- {
- Gadget *g;
-
- for (g=start_of_chain; g->NextGadget !=NULL; g=g->NextGadget);
- g->NextGadget = gadget;
- }
-
-
-
-
- #define FONTHEIGHT 9
- #define FONTWIDTH 8
-
-
- void AlignText( PrecogText *ptext,
- Point size )
- {
- PIXELS width;
- UBYTE flags;
- BYTE Xpad, Ypad;
-
-
- flags = ptext->alignment.Flags;
- Xpad = ptext->alignment.Xpad;
- Ypad = ptext->alignment.Ypad;
-
- if (ptext->IText)
- {
- width = strlen(ptext->IText)*FONTWIDTH;
- }
- else
- {
- width = 0;
- }
-
- /*--------------- ptext->LeftEdge = ? -------------------*/
- if (flags & tx_XCENTER)
- {
- ptext->LeftEdge = size.x/2 - width/2;
- }
- else if (flags & tx_RIGHT)
- {
- if (flags & tx_OUTSIDE)
- ptext->LeftEdge = size.x + Xpad;
- else
- ptext->LeftEdge = size.x - Xpad - width;
- }
- else /* left */
- {
- if (flags & tx_OUTSIDE)
- ptext->LeftEdge = -Xpad - width;
- else
- ptext->LeftEdge = Xpad;
- }
-
- /*--------------- ptext->TopEdge = ? ---------*/
- if (flags & tx_YCENTER)
- {
- ptext->TopEdge = size.y/2 - FONTHEIGHT/2;
- }
- else if (flags & tx_BOTTOM)
- {
- if (flags & tx_OUTSIDE)
- ptext->TopEdge = size.y + Ypad;
- else
- ptext->TopEdge = size.y - Ypad - FONTHEIGHT;
- }
- else /* Top */
- {
- if (flags & tx_OUTSIDE)
- ptext->TopEdge = -Ypad - FONTHEIGHT;
- else
- ptext->TopEdge = Ypad;
- }
-
- }